#ifndef YY_COLORS_INCLUDE
#define YY_COLORS_INCLUDE
#define EPSILON         1.0e-4


// Quadratic color thresholding
// curve = (threshold - knee, knee * 2, 0.25 / knee)
//
half4 QuadraticThreshold(half4 color, half threshold, half3 curve)
{
	// Pixel brightness
	//half br = Max3(color.r, color.g, color.b);
	half br1 = max(color.r, color.g);
	half br = max(br1, color.b);

	// Under-threshold part: quadratic curve
	half rq = clamp(br - curve.x, 0.0, curve.y);
	rq = curve.z * rq * rq;

	// Combine and apply the brightness response curve.
	color *= max(rq, br - threshold) / max(br, EPSILON);

	return color;
}

#endif